using System;
using System.Collections;
using System.Collections.Generic;
using Holoville.HOTween;
using Holoville.HOTween.Core;
using I2.Loc;
using UnityEngine;

public class MapDistrict : MonoBehaviour
{
	[SerializeField]
	public string nameScene;

	[SerializeField]
	private Color lockedColor = Color.gray;

	[SerializeField]
	private Color newCapturedAnimColor = Color.gray;

	[SerializeField]
	private float minBar = 0.2f;

	[SerializeField]
	private float maxBar = 0.8f;

	[SerializeField]
	private Color IncreaseReputationCapturedColor = Color.yellow;

	[SerializeField]
	private Color IncreaseReputationNormalColor = Color.cyan;

	[SerializeField]
	private Color DecreaseReputationColor = Color.red;

	[Header("Links")]
	[SerializeField]
	private GameObject lbName;

	[SerializeField]
	private GameObject lbNameElite;

	[SerializeField]
	private GameObject stats;

	public UITexture districtTexture;

	[SerializeField]
	private UITexture districtIcon;

	[SerializeField]
	private UITexture districtIconElite;

	public UIButton districtButton;

	[SerializeField]
	private GameObject glow;

	[SerializeField]
	private GameObject failGlow;

	[SerializeField]
	private GameObject lostedNote;

	[SerializeField]
	private GameObject unlockedNote;

	[SerializeField]
	private UISprite reputationCapturedBarElite;

	[SerializeField]
	private UISprite reputationCapturedAnimationBarElite;

	[SerializeField]
	private UISprite reputationCapturedBar;

	[SerializeField]
	private UISprite reputationCapturedAnimationBar;

	[SerializeField]
	private UISprite reputationNormalBar;

	[SerializeField]
	private UISprite reputationNormalAnimationBar;

	[SerializeField]
	private GameObject rootCapturedElite;

	[SerializeField]
	private GameObject rootCaptured;

	[SerializeField]
	private GameObject rootNormal;

	[SerializeField]
	private Transform glowCyrcle;

	[SerializeField]
	private Transform glowMoney;

	[SerializeField]
	private GameObject locked;

	[SerializeField]
	private GameObject missionNote;

	[SerializeField]
	private UILabel lockedLable;

	[SerializeField]
	private GameObject cash;

	[SerializeField]
	private GameObject gold;

	[SerializeField]
	private ActivatableButton buttonSingle;

	[SerializeField]
	private ActivatableButton buttonSingleElite;

	[SerializeField]
	private ActivatableButton buttonPvp;

	[SerializeField]
	private ActivatableButton buttonPvpElite;

	[SerializeField]
	private ActivatableButton buttonSandbox;

	[SerializeField]
	private ActivatableButton buttonSandboxElite;

	[SerializeField]
	private GameObject money;

	[SerializeField]
	private UISprite moneyBar;

	[SerializeField]
	private UISprite moneyBarElite;

	[SerializeField]
	private UILabel moneyLable;

	[SerializeField]
	private UILabel moneyLableButton;

	[SerializeField]
	private UILabel moneyLableButtonElite;

	[SerializeField]
	private UILabel moneyTimer;

	[HideInInspector]
	public bool isReputationAnimationInProgres;

	private Animator _animator;

	private float timer;

	private bool isTimerStarted;

	private bool IsElite;

	private ReputationMapInfo dInfo;

	private Color curColor = Color.white;

	private UISprite currentBar;

	private List<UIWidget> allUiChilds = new List<UIWidget>();

	public string lblPopularity;

	public UILabel lblPopLink;

	private MapPopularity popularity;

	private LevelsInfo levelInfo;

	public bool infoIsUpdated;

	private Coroutine _unlockAnimation;

	private UIWidget statsWidget;

	private Coroutine _lockAnimation;

	private Coroutine _animationCycleGlow;

	private bool isTimerShown;

	private float changeIndicatorTimer = 3f;

	private string answer;

	private bool showSeconds;

	public bool isButtonsVisible;

	private Coroutine _switchButtons;

	public bool captured
	{
		get
		{
			return dInfo.state == DistrictState.Captured || dInfo.wasCaptured;
		}
	}

	public bool losted
	{
		get
		{
			return dInfo.wasLosted;
		}
	}

	public string distName
	{
		get
		{
			return nameScene;
		}
	}

	public string levelscene
	{
		get
		{
			return nameScene;
		}
	}

	public static event Action<string> EndOfChangeAmountReputationAnimation;

	public static event Action EndOfAllAnimations;

	public static event Action StartAnimations;

	public static event Action OnTap;

	public event Action DistrictLost;

	private void Awake()
	{
		_animator = GetComponent<Animator>();
		ReputationInterfaceController.UpdateInfo += UpdateInfo;
		ReputationInterfaceController.ShowStats += ShowStatsEventHandler;
		ReputationInterfaceController.ShowNewCaptured += ShowNewCapturedEventHandler;
		MapRoot.OnMapPress += OnMapPressEventHandler;
		MapDistrict.OnTap = (Action)Delegate.Combine(MapDistrict.OnTap, new Action(OnMapPressEventHandler));
		HOTween.Init();
	}

	private void OnDestroy()
	{
		ReputationInterfaceController.UpdateInfo -= UpdateInfo;
		ReputationInterfaceController.ShowStats -= ShowStatsEventHandler;
		ReputationInterfaceController.ShowNewCaptured -= ShowNewCapturedEventHandler;
		MapRoot.OnMapPress -= OnMapPressEventHandler;
		MapDistrict.OnTap = (Action)Delegate.Remove(MapDistrict.OnTap, new Action(OnMapPressEventHandler));
	}

	private void OnEnable()
	{
		infoIsUpdated = false;
	}

	public void InitDistrict()
	{
		Texture mainTexture = Resources.Load<Texture>("ReputationMap/Icons/" + nameScene);
		districtIcon.mainTexture = mainTexture;
		Texture mainTexture2 = Resources.Load<Texture>("ReputationMap/Icons/" + nameScene + "_Elite");
		districtIconElite.mainTexture = mainTexture2;
		allUiChilds.AddRange(GetComponentsInChildren<UIWidget>(true));
		allUiChilds.Add(districtButton.GetComponent<UITexture>());
		lbName.GetComponent<UILabel>().text = LocalizationManager.GetTermTranslation("PVP_map_info/" + nameScene);
		lbNameElite.GetComponent<UILabel>().text = lbName.GetComponent<UILabel>().text;
		levelInfo = ManagerPVPLevels.instance.GetLevelInfo(nameScene);
		Disable();
	}

	private void SetActiveIfNotNull(ActivatableButton button, bool activ)
	{
		if (button != null)
		{
			button.gameObject.SetActive(activ);
		}
	}

	private void OnDisable()
	{
		OnMapPressEventHandler();
	}

	public void ShowStatsEventHandler(bool val)
	{
		stats.SetActive(val);
	}

	private void OnMapPressEventHandler()
	{
		if (isButtonsVisible)
		{
			OnDistictTap();
		}
	}

	public void ShowDistrict(bool val)
	{
		int num = ((!val) ? (-50) : 50);
		foreach (UIWidget allUiChild in allUiChilds)
		{
			allUiChild.depth += num;
		}
	}

	public void SetOnlineBtnActive(bool val)
	{
		buttonPvp.SetActiveButton(val);
		buttonPvpElite.SetActiveButton(val);
		buttonSandbox.SetActiveButton(val);
		buttonSandboxElite.SetActiveButton(val);
	}

	private void ShowNewCapturedEventHandler()
	{
		districtButton.enabled = false;
		if (!dInfo.wasCaptured && !dInfo.wasLosted)
		{
			stats.SetActive(false);
			HOTween.To(districtTexture, 0.5f, new TweenParms().Prop("color", newCapturedAnimColor));
			HOTween.To(districtIcon, 0.5f, new TweenParms().Prop("color", newCapturedAnimColor));
		}
		else
		{
			_animator.ResetTrigger("Interrupt");
			if (dInfo.wasCaptured)
			{
				glow.SetActive(true);
				failGlow.SetActive(false);
				_animator.SetTrigger("Glow");
			}
			else if (dInfo.wasLosted)
			{
				glow.SetActive(false);
				failGlow.SetActive(true);
				_animator.SetTrigger("FailGlow");
			}
			rootCaptured.SetActive(dInfo.wasCaptured && !IsElite);
			rootCapturedElite.SetActive(dInfo.wasCaptured && IsElite);
			rootNormal.SetActive(dInfo.wasLosted);
			ChangeCurrentBar(dInfo.curReputation / dInfo.maxReputation, dInfo.state);
		}
		Invoke("NormalState", 2f);
	}

	public void NormalState()
	{
		if (MapDistrict.EndOfAllAnimations != null)
		{
			MapDistrict.EndOfAllAnimations();
		}
		districtButton.enabled = dInfo.state != DistrictState.Locked;
		if (!dInfo.wasCaptured && !dInfo.wasLosted)
		{
			stats.SetActive(dInfo.state != DistrictState.Locked);
			HOTween.To(districtTexture, 0.5f, new TweenParms().Prop("color", curColor).OnComplete((TweenDelegate.TweenCallback)delegate
			{
				districtButton.enabled = dInfo.state != DistrictState.Locked;
			}));
			HOTween.To(districtIcon, 0.5f, new TweenParms().Prop("color", curColor));
		}
		else
		{
			glow.SetActive(false);
			failGlow.SetActive(false);
			_animator.SetTrigger("Interrupt");
		}
	}

	private void UpdateInfo(bool singleDistrictUpdate)
	{
		infoIsUpdated = false;
		if (!ReputationInterfaceController.instance.districsList.Contains(this))
		{
			ReputationInterfaceController.instance.districsList.Add(this);
		}
		Disable();
		if (!singleDistrictUpdate && !ReputationInterfaceController.instance.districsInfos.TryGetValue(nameScene, out dInfo))
		{
			infoIsUpdated = true;
			return;
		}
		if ((bool)lblPopLink)
		{
			lblPopLink.gameObject.SetActive(false);
		}
		if ((bool)lostedNote)
		{
			lostedNote.SetActive(dInfo.wasLosted);
		}
		if ((bool)unlockedNote)
		{
			unlockedNote.SetActive(dInfo.wasUnlocked);
		}
		if (dInfo.wasLosted && this.DistrictLost != null)
		{
			this.DistrictLost();
		}
		IsElite = dInfo.elite;
		_animator.SetBool("Elite", IsElite);
		if (dInfo.wasUnlocked)
		{
			ShowAnimationUnlock();
		}
		else if (dInfo.wasLocked)
		{
			ShowAnimationLock();
		}
		else if (dInfo.state == DistrictState.Locked)
		{
			SetLocked();
		}
		else
		{
			_animator.SetTrigger("Interrupt");
			InitStats();
			SetUnlocked();
		}
		districtTexture.color = curColor;
		districtIcon.color = curColor;
		MoneyLablesInit((!dInfo.nextSpawnGold) ? dInfo.cashCount : dInfo.nextSpawnGoldCount);
		if (dInfo.spawnCash)
		{
			moneyBar.gameObject.SetActive(!IsElite);
			moneyBarElite.gameObject.SetActive(IsElite);
			StartTimer(dInfo.timeToSpawnMoney);
		}
		infoIsUpdated = true;
	}

	private void ShowAnimationUnlock()
	{
		if (_animationCycleGlow != null)
		{
			StopCoroutine(_unlockAnimation);
		}
		if (statsWidget == null)
		{
			statsWidget = stats.GetComponent<UIWidget>();
		}
		_unlockAnimation = StartCoroutine(UnlockAnimation());
	}

	private IEnumerator UnlockAnimation()
	{
		InitStats();
		SetLocked();
		stats.SetActive(false);
		yield return new WaitForSeconds(0.5f);
		_animator.SetTrigger("Unlocked");
		if (statsWidget != null)
		{
			statsWidget.alpha = 0f;
			stats.SetActive(true);
			UITexture currentIcon = ((!IsElite) ? districtIcon : districtIconElite);
			currentIcon.gameObject.SetActive(true);
			HOTween.To(statsWidget, 1f, new TweenParms().Prop("alpha", 1f));
			HOTween.To(currentIcon, 1f, new TweenParms().Prop("alpha", 1f));
		}
		yield return new WaitForSeconds(1f);
		SetUnlocked();
	}

	private void ShowAnimationLock()
	{
		if (_animationCycleGlow != null)
		{
			StopCoroutine(_lockAnimation);
		}
		if (statsWidget == null)
		{
			statsWidget = stats.GetComponent<UIWidget>();
		}
		_lockAnimation = StartCoroutine(LockAnimation());
	}

	private IEnumerator LockAnimation()
	{
		InitStats();
		SetUnlocked();
		yield return new WaitForSeconds(0.5f);
		_animator.SetTrigger("Lock");
		if (statsWidget != null)
		{
			statsWidget.alpha = 1f;
			locked.SetActive(true);
			UITexture currentIcon = ((!IsElite) ? districtIcon : districtIconElite);
			HOTween.To(statsWidget, 1f, new TweenParms().Prop("alpha", 0f));
			HOTween.To(currentIcon, 1f, new TweenParms().Prop("alpha", 0f));
		}
		yield return new WaitForSeconds(1f);
		SetLocked();
	}

	private void SetLocked()
	{
		districtButton.enabled = false;
		locked.SetActive(true);
		districtIcon.gameObject.SetActive(false);
		districtIconElite.gameObject.SetActive(false);
		lockedLable.gameObject.SetActive(true);
		curColor = lockedColor;
		districtTexture.color = curColor;
		districtIcon.color = curColor;
		if (IsElite)
		{
			lockedLable.text = LocalizationManager.GetTermTranslation("PVP_map_info/elite_locked_get") + " " + dInfo.needCaptureToUnlock;
		}
		else if (dInfo.lockedInTutor)
		{
			lockedLable.text = LocalizationManager.GetTermTranslation("PVP_map_info/block_in_tutor");
		}
		else
		{
			lockedLable.text = LocalizationManager.GetTermTranslation("PVP_map_info/get_level") + " " + dInfo.requiredLevel;
		}
	}

	private void SetUnlocked()
	{
		stats.SetActive(true);
		locked.SetActive(false);
		districtButton.enabled = true;
		curColor = Color.white;
		districtTexture.color = curColor;
		districtIcon.color = curColor;
		if (dInfo.reputationChangedAmount == 0f)
		{
			StartAnimationCycleGlow();
			return;
		}
		if (MapDistrict.StartAnimations != null)
		{
			MapDistrict.StartAnimations();
		}
		StartCoroutine(AnimationNewReputation());
	}

	private void InitStats()
	{
		if (!dInfo.wasCaptured && !dInfo.wasLosted)
		{
			switch (dInfo.state)
			{
			case DistrictState.Captured:
				rootCaptured.SetActive(!IsElite);
				rootCapturedElite.SetActive(IsElite);
				break;
			case DistrictState.Unlocked:
				rootNormal.SetActive(true);
				break;
			case DistrictState.Locked:
				rootNormal.SetActive(true);
				break;
			}
		}
		else
		{
			rootNormal.SetActive(dInfo.wasCaptured);
			rootCaptured.SetActive(dInfo.wasLosted && !IsElite);
			rootCapturedElite.SetActive(dInfo.wasLosted && IsElite);
		}
		if (IsElite)
		{
			districtIconElite.gameObject.SetActive(true);
			lbNameElite.gameObject.SetActive(true);
		}
		else
		{
			districtIcon.gameObject.SetActive(true);
			lbName.gameObject.SetActive(true);
		}
		ChangeCurrentBar(dInfo.curReputation / dInfo.maxReputation, dInfo.state);
	}

	private void MoneyLablesInit(int moneyCount)
	{
		if (IsElite || dInfo.nextSpawnGold)
		{
			moneyLable.text = "[FFD700]" + moneyCount + " G";
		}
		else
		{
			moneyLable.text = moneyCount + " $";
		}
		moneyLableButton.text = moneyLable.text;
		if (moneyLableButtonElite != null)
		{
			moneyLableButtonElite.text = moneyLable.text;
		}
	}

	private void StartAnimationCycleGlow()
	{
		if (_animationCycleGlow != null)
		{
			StopCoroutine(_animationCycleGlow);
		}
		if (dInfo.state == DistrictState.Captured && dInfo.curReputation / dInfo.maxReputation > 0.1f)
		{
			_animationCycleGlow = StartCoroutine(AnimationCycleGlow());
		}
	}

	private IEnumerator AnimationCycleGlow()
	{
		float barFill = (maxBar - minBar) * (dInfo.curReputation / dInfo.maxReputation) + minBar;
		while (true)
		{
			yield return new WaitForSeconds(1f);
			float currentZRotation = 360f - 360f * barFill;
			glowCyrcle.localRotation = Quaternion.Euler(Vector3.forward * currentZRotation);
			glowCyrcle.gameObject.SetActive(true);
			while (currentZRotation <= 360f - 360f * minBar)
			{
				glowCyrcle.localRotation = Quaternion.Euler(Vector3.forward * currentZRotation);
				currentZRotation += 10f;
				yield return null;
			}
			glowCyrcle.gameObject.SetActive(false);
			glowMoney.gameObject.SetActive(true);
			HOTween.To(glowMoney, 0.5f, new TweenParms().Prop("localPosition", Vector3.up * 43f).Ease(EaseType.Linear).OnComplete(delegate
			{
				glowMoney.gameObject.SetActive(false);
				glowMoney.localPosition = Vector3.zero;
			}, new object[0]));
		}
	}

	private IEnumerator AnimationNewReputation()
	{
		districtButton.enabled = false;
		isReputationAnimationInProgres = true;
		int counter = 15;
		if (dInfo.reputationChangedAmount > 0f)
		{
			float tmpRep = dInfo.curReputation - dInfo.reputationChangedAmount;
			while (tmpRep < dInfo.curReputation)
			{
				tmpRep += dInfo.maxReputation * 0.01f;
				ChangeCurrentBar(tmpRep / dInfo.maxReputation, (!dInfo.wasCaptured) ? dInfo.state : DistrictState.Unlocked);
				ChangeCurrentAnimationBar(dInfo.curReputation / dInfo.maxReputation, false, (!dInfo.wasCaptured) ? dInfo.state : DistrictState.Unlocked);
				yield return new WaitForEndOfFrame();
			}
		}
		else
		{
			float realBarFill = dInfo.curReputation / dInfo.maxReputation;
			float currentBarFill = (dInfo.curReputation + Mathf.Abs(dInfo.reputationChangedAmount)) / dInfo.maxReputation;
			float currentAnimationBarFill = currentBarFill;
			ChangeCurrentAnimationBar(currentBarFill, true, (!dInfo.wasLosted) ? dInfo.state : DistrictState.Captured);
			while (currentBarFill > realBarFill)
			{
				currentBarFill -= 0.005f;
				counter--;
				ChangeCurrentBar(currentBarFill, (!dInfo.wasLosted) ? dInfo.state : DistrictState.Captured);
				if (counter == 0)
				{
					yield return StartCoroutine(ShowGlowCyrcle(currentBarFill));
					counter = 15;
				}
				yield return null;
			}
			while (currentAnimationBarFill > realBarFill)
			{
				currentAnimationBarFill -= 0.01f;
				ChangeCurrentAnimationBar(currentAnimationBarFill, true, (!dInfo.wasLosted) ? dInfo.state : DistrictState.Captured);
				yield return null;
			}
		}
		districtButton.enabled = dInfo.state != DistrictState.Locked;
		isReputationAnimationInProgres = false;
		reputationCapturedAnimationBar.gameObject.SetActive(false);
		reputationNormalAnimationBar.gameObject.SetActive(false);
		if (MapDistrict.EndOfChangeAmountReputationAnimation != null)
		{
			MapDistrict.EndOfChangeAmountReputationAnimation(nameScene);
		}
		StartAnimationCycleGlow();
		yield return null;
	}

	private void ChangeCurrentBar(float val, DistrictState state)
	{
		if (state == DistrictState.Captured)
		{
			reputationCapturedBar.gameObject.SetActive(!IsElite);
			reputationCapturedBarElite.gameObject.SetActive(IsElite);
			reputationNormalBar.gameObject.SetActive(false);
			reputationCapturedBar.fillAmount = (maxBar - minBar) * val + minBar;
			reputationCapturedBarElite.fillAmount = reputationCapturedBar.fillAmount;
		}
		else
		{
			reputationCapturedBar.gameObject.SetActive(false);
			reputationCapturedBarElite.gameObject.SetActive(false);
			reputationNormalBar.gameObject.SetActive(true);
			reputationNormalBar.fillAmount = val;
		}
	}

	private void ChangeCurrentAnimationBar(float val, bool decreaseReputation, DistrictState state)
	{
		if (state == DistrictState.Captured)
		{
			reputationCapturedAnimationBar.gameObject.SetActive(!IsElite);
			reputationCapturedAnimationBarElite.gameObject.SetActive(IsElite);
			reputationNormalAnimationBar.gameObject.SetActive(false);
			reputationCapturedAnimationBar.color = ((!decreaseReputation) ? IncreaseReputationCapturedColor : DecreaseReputationColor);
			reputationCapturedAnimationBar.fillAmount = (maxBar - minBar) * val + minBar;
			reputationCapturedAnimationBarElite.color = reputationCapturedAnimationBar.color;
			reputationCapturedAnimationBarElite.fillAmount = reputationCapturedAnimationBar.fillAmount;
		}
		else
		{
			reputationCapturedAnimationBar.gameObject.SetActive(false);
			reputationCapturedAnimationBarElite.gameObject.SetActive(false);
			reputationNormalAnimationBar.gameObject.SetActive(true);
			reputationNormalAnimationBar.color = IncreaseReputationNormalColor;
			reputationNormalAnimationBar.fillAmount = val;
		}
	}

	private IEnumerator ShowGlowCyrcle(float val)
	{
		val = (maxBar - minBar) * val + minBar;
		float currentZRotation = 360f - 360f * val;
		glowCyrcle.localRotation = Quaternion.Euler(Vector3.forward * currentZRotation);
		glowCyrcle.gameObject.SetActive(true);
		while (currentZRotation <= 360f - 360f * minBar)
		{
			glowCyrcle.localRotation = Quaternion.Euler(Vector3.forward * currentZRotation);
			currentZRotation += 10f;
			yield return null;
		}
		glowCyrcle.gameObject.SetActive(false);
		glowMoney.gameObject.SetActive(true);
		HOTween.To(glowMoney, 0.2f, new TweenParms().Prop("localPosition", Vector3.up * 43f).Ease(EaseType.Linear).OnComplete(delegate
		{
			glowMoney.gameObject.SetActive(false);
			glowMoney.localPosition = Vector3.zero;
		}, new object[0]));
	}

	private void Update()
	{
		if (!isTimerStarted)
		{
			return;
		}
		timer -= Time.deltaTime;
		TimeSpan timeSpan = TimeSpan.FromSeconds(timer);
		if (timeSpan.Hours > 0 || timeSpan.Minutes > 0)
		{
			answer = string.Format("{0:D2}:{1:D2}", timeSpan.Hours, timeSpan.Minutes);
		}
		else
		{
			answer = string.Format("{0:D2}", timeSpan.Seconds);
			showSeconds = true;
		}
		moneyTimer.text = answer;
		if (IsElite)
		{
			if ((bool)moneyBarElite)
			{
				moneyBarElite.fillAmount = (dInfo.timeSpawnMoney - timer) / dInfo.timeSpawnMoney;
			}
			moneyBar.fillAmount = 0f;
		}
		else
		{
			moneyBar.fillAmount = (dInfo.timeSpawnMoney - timer) / dInfo.timeSpawnMoney;
			if ((bool)moneyBarElite)
			{
				moneyBarElite.fillAmount = 0f;
			}
		}
		if (timer <= 0f)
		{
			showSeconds = false;
			StopTimer();
			ShowMoney();
			return;
		}
		changeIndicatorTimer -= Time.deltaTime;
		if (changeIndicatorTimer < 0f)
		{
			changeIndicatorTimer = 3f;
			isTimerShown = !isTimerShown;
			moneyLable.gameObject.SetActive(!isTimerShown && !showSeconds);
			moneyTimer.gameObject.SetActive(isTimerShown || showSeconds);
		}
	}

	private void Disable()
	{
		cash.SetActive(false);
		gold.SetActive(false);
		locked.SetActive(false);
		stats.SetActive(false);
		districtIcon.gameObject.SetActive(false);
		districtIconElite.gameObject.SetActive(false);
		if (isButtonsVisible)
		{
			isButtonsVisible = false;
			ShowDistrict(false);
		}
		buttonSingle.gameObject.SetActive(false);
		buttonSingleElite.gameObject.SetActive(false);
		buttonPvp.gameObject.SetActive(false);
		buttonPvpElite.gameObject.SetActive(false);
		buttonSandbox.gameObject.SetActive(false);
		buttonSandboxElite.gameObject.SetActive(false);
		lbNameElite.gameObject.SetActive(false);
		lbName.gameObject.SetActive(false);
		reputationNormalBar.gameObject.SetActive(false);
		reputationCapturedBar.gameObject.SetActive(false);
		reputationCapturedBarElite.gameObject.SetActive(false);
		moneyLable.gameObject.SetActive(false);
		moneyTimer.gameObject.SetActive(false);
		money.SetActive(false);
		glow.SetActive(false);
		failGlow.SetActive(false);
		rootCaptured.SetActive(false);
		rootCapturedElite.SetActive(false);
		rootNormal.SetActive(false);
		reputationCapturedAnimationBar.gameObject.SetActive(false);
		reputationCapturedAnimationBarElite.gameObject.SetActive(false);
		reputationNormalAnimationBar.gameObject.SetActive(false);
		if (ReputationInterfaceController.instance != null && ReputationInterfaceController.instance.mapBackground != null)
		{
			ReputationInterfaceController.instance.mapBackground.SetActive(false);
		}
	}

	public void StartTimer(float timeToReward)
	{
		timer = timeToReward;
		isTimerStarted = true;
		changeIndicatorTimer = 3f;
		moneyTimer.gameObject.SetActive(true);
		money.SetActive(true);
	}

	public void StopTimer()
	{
		timer = 0f;
		isTimerStarted = false;
		moneyLable.gameObject.SetActive(false);
		moneyTimer.gameObject.SetActive(false);
	}

	public void ShowMoney()
	{
		moneyLableButton.gameObject.SetActive(true);
		cash.SetActive(!IsElite && !dInfo.nextSpawnGold);
		gold.SetActive(IsElite || dInfo.nextSpawnGold);
	}

	public IEnumerator OnMoneyTap()
	{
		if (ReputationInterfaceController.instance.mapBackground.activeSelf && !isButtonsVisible)
		{
			OnDistictTap();
			yield break;
		}
		if (dInfo.elite)
		{
			FlyingPointsController.instance.AddFlyingPointsByAmount(base.gameObject.transform.position, PointsType.Gold, dInfo.cashCount, false);
		}
		else if (dInfo.nextSpawnGold)
		{
			FlyingPointsController.instance.AddFlyingPointsByAmount(base.gameObject.transform.position, PointsType.Gold, dInfo.nextSpawnGoldCount, false);
		}
		else
		{
			FlyingPointsController.instance.AddFlyingPointsByAmount(base.gameObject.transform.position, PointsType.Cash, dInfo.cashCount, false);
		}
		_animator.ResetTrigger("Interrupt");
		_animator.SetTrigger("CashCollect");
		yield return new WaitForSeconds(1f);
		cash.SetActive(false);
		gold.SetActive(false);
		money.SetActive(false);
		MoneyLablesInit(dInfo.cashWitoutAdditoinal);
		UpdateInfo(true);
	}

	public void OnLockedTap()
	{
		_animator.SetTrigger("Locked");
	}

	public void OnDistictTap()
	{
		if (MapDistrict.OnTap != null && !isButtonsVisible)
		{
			MapDistrict.OnTap();
		}
		isButtonsVisible = !isButtonsVisible;
		_animator.ResetTrigger("Interrupt");
		if (isButtonsVisible)
		{
			HOTween.To(base.transform, 0.5f, new TweenParms().Prop("localScale", Vector3.one).Ease(EaseType.EaseInOutBack));
			_animator.SetTrigger("ButtonsReveal");
		}
		else
		{
			HOTween.To(base.transform, 0.5f, new TweenParms().Prop("localScale", Vector3.one * 0.7f).Ease(EaseType.EaseInOutBack));
			_animator.SetTrigger("ButtonsReverse");
		}
		if ((bool)lblPopLink)
		{
			lblPopLink.gameObject.SetActive(isButtonsVisible);
		}
		UpdateButtonsColliders(isButtonsVisible);
		if (_switchButtons != null)
		{
			StopCoroutine(_switchButtons);
			_switchButtons = null;
		}
		if (base.gameObject.activeSelf && base.gameObject.activeInHierarchy)
		{
			_switchButtons = StartCoroutine(UpdateButtonsState());
		}
		ReputationInterfaceController.instance.mapBackground.SetActive(isButtonsVisible);
		ShowDistrict(isButtonsVisible);
	}

	private IEnumerator UpdateButtonsState()
	{
		if (isButtonsVisible)
		{
			yield return null;
		}
		else
		{
			yield return new WaitForSeconds(0.5f);
		}
		buttonSingle.gameObject.SetActive(isButtonsVisible && !dInfo.elite);
		buttonSingleElite.gameObject.SetActive(isButtonsVisible && dInfo.elite);
		buttonPvp.gameObject.SetActive(isButtonsVisible && !dInfo.elite);
		buttonPvpElite.gameObject.SetActive(isButtonsVisible && dInfo.elite);
		buttonSandbox.gameObject.SetActive(isButtonsVisible && !dInfo.elite);
		buttonSandboxElite.gameObject.SetActive(isButtonsVisible && dInfo.elite);
		_switchButtons = null;
	}

	public void UpdateButtonsColliders(bool val)
	{
		buttonSingle.SetActiveButton(val);
		buttonSingleElite.SetActiveButton(val);
		buttonPvp.SetActiveButton(val);
		buttonPvpElite.SetActiveButton(val);
		buttonSandbox.SetActiveButton(val);
		buttonSandboxElite.SetActiveButton(val);
	}

	public void LoadLevel()
	{
		settings.SaveCathedExeptionsToStorager();
		controllerConnectPhoton.thisScript.connectRandomRoom(levelInfo.nameScene, levelInfo.modeGame);
	}

	public void LoadCity()
	{
		settings.SaveCathedExeptionsToStorager();
		LevelsInfo levelsInfo = ManagerPVPLevels.instance.GetLevelInfo("Level1");
		controllerConnectPhoton.thisScript.connectRandomRoom(levelsInfo.nameScene, levelsInfo.modeGame);
	}

	public void LoadPVECity()
	{
		settings.SaveCathedExeptionsToStorager();
		controllerMenu.thisScript.playOfflineMode();
	}
}
